package day14.demo3;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @Auther:小陈的Java
 */
public class ThreadPoolDemo {
    public static void main(String[] args) throws Exception{
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        executorService.execute(new ThreadA());
        Future future = executorService.submit(new TheadB());
        Object result = future.get();
        System.out.println(result);
    }
}
class ThreadA implements Runnable{
    @Override
    public void run() {
        for (int i = 1; i <=100; i++) {
            System.out.println(Thread.currentThread().getName()+"："+i);
        }
    }
}
class TheadB implements Callable{
    @Override
    public Object call() throws Exception {
        int sum = 0;
        for (int i = 1; i <=100 ; i++) {
            System.out.println(Thread.currentThread().getName()+"："+i);
            sum+=i;
        }
        return sum;
    }
}
